package fi.foyt.cs.oauth.provider.data;

import java.util.Collection;

import org.restlet.ext.oauth.provider.data.Client;
import org.restlet.ext.oauth.provider.data.ClientStore;

import fi.foyt.cs.controller.OAuthController;
import fi.foyt.cs.persistence.domainmodel.oauth.AuthorizedClient;

public class GAEClientStore extends ClientStore {

  public GAEClientStore() {
    super(new GAETokenGenerator());
  }

  public Client createClient(String clientId, String redirectUri) {
    return null;
  }

  public Client createClient(String clientId, String clientSecret, String redirectUri) {
    return null;
  }

  public void deleteClient(String id) {

  }

  public Client findById(String id) {
    OAuthController oAuthController = new OAuthController();
    AuthorizedClient authorizedClient = oAuthController.findAuthorizedClientByClientId(id);
    return new GAEClient(authorizedClient.getClientId(), authorizedClient.getClientSecret(), authorizedClient.getReturnUrl(), authorizedClient.getClientName());
  }

  @Override
  public Collection<Client> findClientsForUser(String userid) {
    // TODO: Implement
    return null;
  }

}
